//
//  LeaderRepairCell.m
//  PropertyMananger
//
//  Created by Mansion on 17/3/5.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "LeaderRepairCell.h"

@implementation LeaderRepairCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString * CellID = @"LeaderRepairCellID";
    LeaderRepairCell * cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (!cell) {
        
        cell = [[LeaderRepairCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.repairAddrLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repairAddrLabel];
        
        self.repairAddrLabel.textColor = BHColor(51, 51, 51);
        self.repairAddrLabel.textAlignment = NSTextAlignmentLeft;
        self.repairAddrLabel.font = BHFont(15);
        self.repairAddrLabel.textColor = Theme_Color;
        self.repairAddrLabel.text = @"报修地址:2323434343433";
        //  self.equipmentCodeLabel.backgroundColor = BHRandColor;
        
        [self.repairAddrLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(14);
            make.top.equalTo(self).with.offset(12.5);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 40, 25));
        }];
        
//        UIImageView * arrowImg = [[UIImageView alloc]init];
//        [self.contentView addSubview:arrowImg];
//        arrowImg.image = IMG(@"ico_work_order_next");
//        
//        [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.trailing.equalTo(self).with.offset(-15);
//            make.centerY.equalTo(self.repairAddrLabel).with.offset(0);
//            make.size.mas_equalTo(CGSizeMake(8, 14));
//        }];
        
        UIView * lineView = [[UIView alloc]init];
        [self.contentView addSubview:lineView];
        
        lineView.backgroundColor = BHColor(230, 230, 230);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 1));
            make.top.equalTo(self.repairAddrLabel.mas_bottom).with.offset(12.5);
        }];
        
        self.repairMan = [[UILabel alloc]init];
        [self.contentView addSubview:self.repairMan];
        
        self.repairMan.textColor = BHColor(102, 102, 102);
        self.repairMan.textAlignment = NSTextAlignmentLeft;
        self.repairMan.font = BHFont(15);
        self.repairMan.text  = @"维修人:";
        
        [self.repairMan mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(lineView).with.offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.repairManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repairManLabel];
        
        self.repairManLabel.textColor = BHColor(51, 51, 51);
        self.repairManLabel.textAlignment = NSTextAlignmentLeft;
        self.repairManLabel.font = BHFont(15);
        self.repairManLabel.text  = @"监控摄像头";
        // self.complianManLabel.backgroundColor = BHRandColor;
        
        [self.repairManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.repairMan.mas_trailing).with.offset(0);
            make.top.equalTo(self.repairMan).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        self.processState = [[UILabel alloc]init];
        [self.contentView addSubview:self.processState];
        
        self.processState.textColor = BHColor(102, 102, 102);
        self.processState.textAlignment = NSTextAlignmentLeft;
        self.processState.font = BHFont(15);
        self.processState.text  = @"处理状态:";
        
        [self.processState mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.repairMan).with.offset(0);
            make.top.equalTo(self.repairMan.mas_bottom).with.offset(10);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.processStateLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.processStateLabel];
        
        self.processStateLabel.textColor = [UIColor redColor];
        self.processStateLabel.textAlignment = NSTextAlignmentLeft;
        self.processStateLabel.font = BHFont(15);
        self.processStateLabel.text  = @"WFH-455454";
        //   self.timeLabel.backgroundColor = BHRandColor;
        
        [self.processStateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.processState.mas_trailing).with.offset(0);
            make.top.equalTo(self.processState).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2+50, 25));
        }];
        
        self.repairTime = [[UILabel alloc]init];
        [self.contentView addSubview:self.repairTime];
        
        self.repairTime.textColor = BHColor(102, 102, 102);
        self.repairTime.textAlignment = NSTextAlignmentLeft;
        self.repairTime.font = BHFont(15);
        self.repairTime.text  = @"报修时间:";
        
        [self.repairTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.processState).with.offset(0);
            make.top.equalTo(self.processState.mas_bottom).with.offset(10);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.repairTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repairTimeLabel];
        
        self.repairTimeLabel.textColor = BHColor(51, 51, 51);
        self.repairTimeLabel.textAlignment = NSTextAlignmentLeft;
        self.repairTimeLabel.font = BHFont(15);
        self.repairTimeLabel.text  = @"在用";
        
        [self.repairTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(self.repairTime.mas_trailing).with.offset(0);
            make.centerY.equalTo(self.repairTime).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 100, 50));
        }];
        
        self.completeTime = [[UILabel alloc]init];
        [self.contentView addSubview:self.completeTime];
        
        self.completeTime.textColor = BHColor(102, 102, 102);
        self.completeTime.textAlignment = NSTextAlignmentLeft;
        self.completeTime.font = BHFont(15);
        self.completeTime.text  = @"完成时间:";
        
        [self.completeTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.repairTime).with.offset(0);
            make.top.equalTo(self.repairTime.mas_bottom).with.offset(10);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.completeTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.completeTimeLabel];
        
        self.completeTimeLabel.textColor = BHColor(51, 51, 51);
        self.completeTimeLabel.textAlignment = NSTextAlignmentLeft;
        self.completeTimeLabel.font = BHFont(15);
        self.completeTimeLabel.numberOfLines = 3;
        self.completeTimeLabel.text  = @"1栋3单元6层楼梯间1栋3单元6层楼梯间1栋3单元6层楼梯间1栋3单元6层楼梯间1栋3单元6层楼梯间";
        
        [self.completeTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(self.completeTime.mas_trailing).with.offset(0);
            make.centerY.equalTo(self.completeTime).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 100, 25));
        }];
        
    }
    return self;
}

- (void)setModel:(PublicRepairModel *)model{

    _model = model;
    
    self.repairAddrLabel.text = [NSString stringWithFormat:@"报修地址:%@",model.RepairAddr];
    
    if (self.model.rWorkerModeArray.count == 0) {
        
        self.repairManLabel.text = @"";
    }else{
    
        for (RWorkerMode * workModel in self.model.rWorkerModeArray) {
            
            self.repairManLabel.text = [NSString stringWithFormat:@"%@",workModel.RealName];
        }

    }
    
    if (model.ApplyTime == nil) {
        
        self.repairTimeLabel.text = @"";
    }else{
    
         self.repairTimeLabel.text = [NSString stringWithFormat:@"%@",model.ApplyTime];
    }
   
    
    if (model.FinishTime != nil) {
      
        self.completeTimeLabel.text = [NSString stringWithFormat:@"%@",model.FinishTime];
    }else{
    
    self.completeTimeLabel.text = @"";
    }
   
    
    if ([model.ProcessState isEqualToString:@"10"]) {
        
     self.processStateLabel.text = @"待处理";
        
    }else if ([model.ProcessState isEqualToString:@"30"]){
    
      self.processStateLabel.text = @"处理中";
        
    }else if ([model.ProcessState isEqualToString:@"100"]){
        
         self.processStateLabel.text = @"已处理";
        
    }else if ([model.ProcessState isEqualToString:@"40"]){
        
          self.processStateLabel.text = @"已回访";
        
    }else if ([model.ProcessState isEqualToString:@"50"]){
        
          self.processStateLabel.text = @"已完成";
    }
    
    
    
}


@end
